<?php

namespace Rblog\Module\Admin\Model;

class Setup extends \Rexzy\App\Model {

    protected $_table = 'setup';
    
    /**
     * 更新设置
     * 
     * @param array() $data 设置的数据
     * @return boolean 
     */
    public function seting( $data ) {
        foreach( $data as $key => $val ) {
            $newdata = array( 'value' => $val );
            $where = array( 'keyword'=> $key );
            $this->update( $newdata, $where );
        }
        return true;
    }
    
    /**
     * 查询网站现时保存的设置数据
     * 
     * @return array() 现时设置的数据
     */
    public function get() {
        $setval = $this->selectAll( '*' );
        $data = array();
        foreach( $setval as $key => $val ) {
            $data[$val['keyword']] = $val['value'];
        }
        return $data;
    }
}
